home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Arsenal Files 6
/
The Arsenal Files 6 (Arsenal Computer).ISO
/
prg_casm
/
jlvesa11.zip
/
JLVESA02.ASM
< prev
next >
Wrap
Assembly Source File
|
1996-01-03
|
7KB
|
265 lines
; This routine is part of VESA SVGA -library
;
; Copyright 1994 Johannes Lehtinen
; All rights reserved
model large,c
p386
include "jlvesads.asm"
segment jlvesa02_TEXT USE16 'CODE'
assume cs:jlvesa02_TEXT
; Information for default VESA modes, starting from 100H
; List of default modes that can be used
def_modes dw 100H,101H,103H,105H,107H
; Width of modes listed before
def_width dw 640,640,800,1024,1280
; Height of modes listed before
def_height dw 400,480,600,768,1024
; Space for VESA video/mode information
work_space db 256 dup(?)
; JLFlag JVSVGA_SetMode(JVUWord mode)
;
; Sets given VESA video mode. Mode should be 256 color mode. Function returns
; 0 if succesfull and 1 if not.
proc JVSVGA_SetMode far
public JVSVGA_SetMode
push bp
mov bp,sp
push ds
push di
push es
mov ax,JLVesa_Data
mov ds,ax
; First check version number by loading VESA info
mov ax,cs
mov es,ax ; ES:DI = VESA info
mov di,offset work_space
mov ax,4f00H ; Get VESA info
int 10H ; Call VESA BIOS
cmp ax,4fH ; Check if succesfull
jne error1 ; Error, return
; Calculate amount of memory
xor eax,eax
mov ax,[es:di+18]
shl eax,16
mov [ds:Size],eax
; Check version number
cmp [byte ptr es:di+5],1 ; Check if major > 1
ja short success2
jb error1 ; Check if major < 1
cmp [byte ptr es:di+4],1 ; Check if minor >= 1
jb error1
; Get mode information
success2:
mov ax,4f01H ; Get mode info
mov cx,[ss:bp+6] ; CX = mode
int 10H ; Call VESA BIOS
cmp ax,4fH ; Check if succesfull
jne error1 ; Error, return
; Check if mode supported
test [byte ptr es:di],1 ; Test if supported
jz error1 ; Not supported
; Check through nonoptional info
test [byte ptr es:di],8 ; Check that mode is color mode
jz error1
test [byte ptr es:di],16 ; Check that mode is graphics mode
jz error1
cmp [word ptr es:di+6],64 ; Check that window size is equal to or below 64K
ja error1
; Check that there is window for read
mov al,[es:di+2] ; Check window A for possible read window
and al,3
cmp al,3
jne short read_check_b
mov ax,[es:di+8] ; Get information for win A
mov [ds:RWSeg],ax
mov [ds:RWin],0
jmp short check_write
read_check_b:
mov al,[es:di+3] ; Check window B for possible read window
and al,3
cmp al,3
jne error1 ; Read window not found
mov ax,[es:di+10] ; Get information for win B
mov [ds:RWSeg],ax
mov [ds:RWin],1
; Check that there is window for write
check_write:
mov al,[es:di+2] ; Check window A for possible write window
and al,5
cmp al,5
jne short write_check_b
mov ax,[es:di+8] ; Get information for win A
mov [ds:WWSeg],ax
mov [ds:WWin],0
jmp short test_optional
write_check_b:
mov al,[es:di+3] ; Check window B for possible write window
and al,5
cmp al,5
jne error1 ; Write window not found
mov ax,[es:di+10] ; Get information for win B
mov [ds:WWSeg],ax
mov [ds:WWin],1
; Test if there is optional info available
test_optional:
test [byte ptr es:di],2 ; Test if there is optional info available
jz check_def ; No optional info, check from table if usable
; Check trough optional info
cmp [byte ptr es:di+19H],8 ; Check that mode has 256 colors
jne error1
cmp [byte ptr es:di+1bH],4 ; Check that memory model is packed pixels
jne error1
; Read optional info
mov ax,[es:di+12H] ; Read width
mov [ds:Width],ax
mov ax,[es:di+14H] ; Read height
mov [ds:Height],ax
mov ax,[es:di+1dH] ; Read number of pages
inc ax
mov [ds:Pages],al
; Read nonoptional info
readinfo:
mov ax,[es:di+10H] ; Read logical width
mov [ds:LWidth],ax
xor eax,eax ; Read window size
mov ax,[es:di+6]
cmp ax,64 ; Check that window size <= 64k
jbe short size_ok
mov ax,64
size_ok:
shl eax,10 ; Convert size from kilobytes to bytes
mov [ds:WSize],eax
xor eax,eax ; Read window granularity
mov ax,[es:di+4]
cmp ax,64 ; Check that granularity <= 64k
ja error1
shl eax,10 ; Convert size from kilobytes to bytes
mov [ds:Granularity],eax
mov eax,[es:di+0cH] ; Read address of window positioning function
mov [ds:PosFunc],eax
mov [ds:RAStart],0 ; Reset window to the start of video memory
mov [ds:WAStart],0
mov [ds:AStart],0
mov [ds:VStart],0
; Select mode
mov ax,4f02H ; Set mode
mov bx,[ss:bp+6]
int 10H
cmp ax,4fH
jne short error1
; Calculate size of video page
xor eax,eax
xor ebx,ebx
mov ax,[ds:LWidth] ; Multiply logical width with height
mov bx,[ds:Height]
mul ebx
mov [ds:PSize],eax
; Set display start
mov ax,4f05H
xor bx,bx
xor cx,cx
xor dx,dx
int 10H
; Position window to the start of video memory
xor bh,bh ; Position read window
mov bl,[ds:RWin]
xor dx,dx
call [ds:PosFunc]
xor bh,bh ; Position write window
mov bl,[ds:WWin]
xor dx,dx
call [ds:PosFunc]
; Return succesfully
pop es
pop di
pop ds
pop bp
mov al,0
retf
; This routine is called when something goes wrong
error1:
pop es
pop di
pop ds
pop bp
mov al,1
retf
; This routine is called if no optional info is available
check_def:
xor di,di ; DI = offset of current mode
mov ax,[ss:bp+6] ; AX = mode
check_loop:
cmp [cs:def_modes+di],ax ; Check if correct mode found on list
je short check_found
add di,2 ; Check next mode
cmp di,10 ; Check if modes left
jb check_loop
jmp short error1 ; Mode was not supported
check_found: ; Mode was found, get information from table
mov ax,[cs:def_width+di] ; Read width
mov [ds:Width],ax
mov ax,[cs:def_height+di] ; Read height
mov [ds:Height],ax
mov [ds:Pages],1
jmp readinfo
endp JVSVGA_SetMode
ends
end